<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>04-列表锚点-滚动索引-例子2</title>
</head>

<body>


    <style>
        .container {
            background-color: oldlace;
            height: 200px;
            width: 140px;
            overflow: auto;
        }

        .container div {
            height: 20px;
            background-color: aqua;
            border: 1px solid;
        }

        .container .header {
            position: sticky;
            top: 0;
            background-color: rgb(187, 153, 153);
        }
    </style>

    <div class="container">
        <div class="header">a</div>
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div class="header">b</div>
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div class="header">c</div>
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div class="header">d</div>
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div class="header">e</div>
        <div>1</div>
        <div>2</div>
        <div>3</div>
    </div>

</body>

</html>